#include<bits/stdc++.h>
#define int long long
using namespace std;
int read(){
	bool flag=0;
	char c=getchar();
	while(c<48){
		if(c=='-') flag=1;
		c=getchar();
	}
	int x=0;
	while(c>=48){
		x=x*10+(c-48);
		c=getchar();
	}
	if(flag) x=-x;
	return x;
}
const int N=1e5+10;
struct CAR{
	int d,v,a;
}car[N];
int p[N];
int csd[1000010];
int scsd[1000010];
bool have(int l,int r){
	return (scsd[r]-scsd[l-1])>0;
}
void solve(){
	memset(csd,0,sizeof csd);
	memset(scsd,0,sizeof scsd);
	bool special_a=1;
	bool special_b=1;
	bool special_c=1;
	int n,m,L,V;
	n=read();
	m=read();
	L=read();
	V=read();
	int maxv=-1,cntCS=0;
	for(int i=1;i<=n;i++){
		car[i].d=read();
		car[i].v=read();
		car[i].a=read();
		maxv=max(maxv,car[i].v);
		if(car[i].a!=0) special_a=0;
		if(car[i].a<=0) special_b=0;
		if(car[i].a>=0) special_c=0;
	}
	for(int i=1;i<=m;i++) p[i]=read();
	for(int i=1;i<=m;i++) csd[p[i]]=1;
	for(int i=1;i<=1000000;i++) scsd[i]=scsd[i-1]+csd[i];
	if(special_a){
		for(int i=1;i<=n;i++){
			if(car[i].d<=p[m]&&car[i].v>V) cntCS++;
		}
		cout<<cntCS<<' ';
		if(maxv>V){
			cout<<m-1<<'\n';
		}else{
			cout<<m<<'\n';
		}
	}else{
		vector<pair<int,int>> req;
		// int cf[1000010];
		// memset(cf,0,sizeof cf);
		for(int i=1;i<=n;i++){
			if(car[i].a>0){
				if(car[i].v>V){
					if(car[i].d<=p[m]){
						cntCS++;
						// cf[car[i].d]++;
						// cf[L+1]--;
						req.push_back({car[i].d,L});
					}
				}else{
					double place=1.0*car[i].d+(((1.0*V)*(1.0*V)-(1.0*car[i].v)*(1.0*car[i].v))/(2.0*car[i].a));
					int iplace=ceil(place);
					int ip2=iplace-1;
					if(place>L) continue;
					if((fabs((double)iplace-place)<=1e-8)){
						if(have(iplace+1,L)){
							cntCS++;
							// cf[iplace+1]++;
							// cf[L+1]--;
							req.push_back({iplace+1,L});
						}
					}else if((fabs((double)ip2-place)<=1e-8)){
						if(have(iplace,L)){
							cntCS++;
							// cf[iplace]++;
							// cf[L+1]--;
							req.push_back({iplace,L});
						}
					}else{
						if(have(iplace,L)){
							cntCS++;
							// cf[iplace]++;
							// cf[L+1]--;
							req.push_back({iplace,L});
						}
					}
				}
			}else if(car[i].a==0){
				if(car[i].d<=p[m]&&car[i].v>V){
					cntCS++;
					// cf[car[i].d]++;
					// cf[L+1]--;
					req.push_back({car[i].d,L});
				}
			}else{//<0
				if(car[i].v<=V){
					
				}else{
					double place=1.0*car[i].d+(((1.0*V)*(1.0*V)-(1.0*car[i].v)*(1.0*car[i].v))/(2.0*car[i].a));
					int iplace=ceil(place);
					int ip2=iplace-1;
					// if(place>L) continue;
					if((fabs((double)iplace-place)<=1e-8)){
						if(have(car[i].d,ip2)){
							cntCS++;
							// cf[car[i].d]++;
							// cf[ip2+1]--;
							req.push_back({car[i].d,ip2});
						}
					}else if((fabs((double)ip2-place)<=1e-8)){
						if(have(car[i].d,ip2-1)){
							cntCS++;
							// cf[car[i].d]++;
							// cf[ip2]--;
							req.push_back({car[i].d,ip2-1});
						}
					}else{
						if(have(car[i].d,ip2)){
							cntCS++;
							// cf[car[i].d]++;
							// cf[ip2+1]--;
							req.push_back({car[i].d,ip2});
						}
					}
				}
			}
		}
		cout<<cntCS<<' ';
		// sort(req.begin(),req.end(),greater<pair<int,int>>());

		// for(auto c:req){
		// 	cout<<c.first<<' '<<c.second<<'\n';
		// }
		// int last=-1;
		// for(int i=1,j=0;i<=m&&j<(int)req.size();){
		// 	if(last==-1){
		// 		if()
		// 	}
		// }
		int nmax=-1,nmin=INT_MAX;
		int nd=0;
		sort(req.begin(),req.end());
		for(int i=1,j=0;i<=m&&j<(int)req.size();){
			if(p[i]>=nmax&&p[i]<=nmin){
				for(;j<(int)req.size();j++){
					if(p[i]>=req[j].first&&p[i]<=req[j].second){
						nmax=max(nmax,req[j].first);
						nmin=min(nmin,req[j].second);
					}else{
						i++;
						break;
					}
				}
			}else{
				nd++;
				nmax=-1,nmin=INT_MAX;
			}
		}
		cout<<m-nd-1<<'\n';
	}
	
}
signed main(){
	freopen("detect.in","r",stdin);
	freopen("detect.out","w",stdout);
	int t;
	t=read();
	while(t--){
		solve();
	}
	// int i=1;
	// car[1].d=1;
	// car[1].a=4;
	// car[1].v=1;
	// int V=3;
	// double place=8.0000000000001;
	// int iplace=ceil(place);
	// int ip2=iplace-1;
	// if((fabs((double)iplace-place)<=1e-8)||(fabs((double)ip2-place)<=1e-8)){
	// 	cout<<1<<'\n';
	// }else{
	// 	cout<<0<<'\n';
	// }
	return 0;
}